package com.example.curd.controller;


import com.example.curd.entity.Role;
import com.example.curd.mapper.RoleMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dakai
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/role")
public class RoleController {

  @Autowired
  RoleMapper roleMapper;

  @ApiOperation("查询全部角色")
  @GetMapping("/SelectAll")
  List<Role> SelectAll(){
    return roleMapper.SelectAll();
  }

  @ApiOperation("查询角色")
  @GetMapping("/SelectOne/{id}")
  List<Role> SelectOne(@PathVariable Integer id){
    return roleMapper.SelectOne(id);
  }

  @ApiOperation("删除角色")
  @DeleteMapping("/DeleteOne/{id}")
  Integer DeleteOne(@PathVariable Integer id){
    return roleMapper.DeleteOne(id);
  }

  @ApiOperation("添加角色")
  @PostMapping("/InsertOne")
  Integer InsertOne(@RequestBody Role role){
    return roleMapper.InsertOne(role);
  }

  @ApiOperation("更新角色")
  @PutMapping("/UpdateOne")
  Integer UpdateOne(@RequestBody Role role){
    return roleMapper.UpdateOne(role);
  }
}
